﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="FileTaggerData" namespace="FileTaggerData.Domain">
  <class name="TaggedFile" table="tbl_files">
    <id name="ID" column="ID" type="System.Int32">
      <generator class="increment"/>
    </id>
    <property name="FilePath" column="FILE_PATH" type="System.String" update="false" unique="true"/>
    <property name="Description" column="FILE_DESCRIPTION" type="System.String"/>
    <property name="Created" column="DATE_INSERTED" type="System.DateTime" insert="false" update="false"/>
    <property name="Modified" column="DATE_MODIFIED" type="System.DateTime" insert="false" update="false"/>
    <bag name="Tags" table="TBL_TAG_FILE">
      <key column="FILE_ID"/>
      <many-to-many class="FileTag" column="TAG_ID"/>
    </bag>
    <sql-insert>
      insert into tbl_files(FILE_PATH,FILE_DESCRIPTION,DATE_INSERTED,DATE_MODIFIED) values (?,?,datetime(),datetime());
    </sql-insert>
    <sql-update>
      update tbl_files set FILE_DESCRIPTION = ?, DATE_MODIFIED = datetime() where ID = ?;
    </sql-update>
    <sql-delete>
      delete from tbl_tag_file where FILE_ID = @p0;
      delete from tbl_files where ID = ?;
    </sql-delete>
  </class>
</hibernate-mapping>